<!doctype html>
<html lang="en" class="feedback">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>延时页面</title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/feedback-page.css" />
		<style>
			.mui-bar{
				background-color: rgba(0,153,204,.9);
			}
			.mui-icon{
				color: #FFFFFF;
			}
			.delayDateUnit{
				width: 70px;
				height: 40px;
			}
			#send{
				width: 90%;
				height: 100%;
				float: left;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title" style="color: #FFFFFF;">延时原因</h1>
		</header>
		<div class="mui-bar mui-bar-tab btn-detail"  id='btn-opears' style="background: rgba(0,0,0,0);-webkit-box-shadow:0 0 0px rgba(0,0,0,.85);">
			<button class="mui-btn mui-btn-block mui-btn-primary" id='send'>提交</button>
		</div>
		<div class="mui-content">
			<p class="mui-h4">延时原因</p>
			<div class="row mui-input-row">
				<textarea id='question' class="mui-input-clear question" placeholder="请详细描述该任务延时的原因..."></textarea>
			</div>
			<p class="mui-h4">
				时间
				<input type="number"  id="delayDate" style="width: 70px;height: 40px;" placeholder="0"/>
				单位
				<span class="mui-select">
					<select class="delayDateUnit mui-h4" id="delayDateUnit">
					<option value="3">天</option>
					<option value="2">时</option>
					<option value="1">分</option>
				</select>
				</span>
			</p>
			<!--<button id='send' type="button" class="mui-btn mui-btn-success">提交</button>-->
		</div>
		<script src="js/mui.min.js"></script>
		<script type="text/javascript" src="../js/md5.js" ></script>
		<script type="text/javascript" src="../js/uuid.js" ></script>
		<script type="text/javascript" src="../js/utils.js" ></script>
		<script>
		(function($, doc) {
				
			$.init({
				statusBarBackground: '#f7f7f7'
			});
				
			$.plusReady(function() {
				var self = plus.webview.currentWebview();
				var taskId = self.taskId ;
				var search = self.search;
				var delayBtn = doc.getElementById('send');
				var delayBox = doc.getElementById('question');
				var delayDate = doc.getElementById("delayDate");
				var delayDateUnit = doc.getElementById("delayDateUnit");
				delayBtn.addEventListener('tap', function(event) {
					var reson = delayBox.value ;
					var delayNum = delayDate.value;
					var dateUnit = delayDateUnit.value;
					var reg = /\S/;
					var regDate = /\d/;
					if(!reg.test(reson)){
						$.toast('亲,别偷懒，延时理由是一定要写的哦') ;
						return;
					}
					
					if (reson.length < 5) {
						$.toast('亲，延时理由太少了，写多点吧') ;
						return ;
					}
					
					if(!regDate.test(delayNum) || 0 > delayNum){
						$.toast("亲,时间填的不对哦");
						return;
					}
					plus.nativeUI.showWaiting("正在处理");
					xhz.ajax(URL_TASK_DELAY,{taskId: taskId,delayDate:delayNum,delayDateUnit:dateUnit, description: reson},function(data){
						if(data && data.code == 1){
							plus.nativeUI.closeWaiting();
							mui.toast("再忙也要注意身体哦，工单已经被延时了") ;
							var lastPage = plus.webview.getWebviewById('emc-task-search');
							mui.fire(lastPage, "taskinfo:removed",{id:'node_'+taskId});
							var cview = plus.webview.currentWebview();
//							var unacceptPage = plus.webview.currentWebview().parent();
//							mui.fire(unacceptPage, "unaccept:back",{id:'node_'+taskId});
							cview.close() ;
							return ;
						}
						mui.toast(data.message) ;
					});
				});
				
			});
		}(mui, document));
		</script>
	</body>
</html>